# -*- coding: utf-8 -*-
# @Time    : 2021/6/27 23:28
# @Author  : chron
# @FileName: locustfile.py
# @Software: PyCharm
# @E-mail  : chron@foxmil.com
from locust import task, between
from locust.contrib.fasthttp import FastHttpUser
import time


class QuickstartUser(FastHttpUser):
    # 每个用户等待1到2.5秒再次发起请求
    wait_time = between(1, 2.5)

    # 设置权重
    @task
    def hello_world(self):
        with self.client.get("/") as f:
            print(f.text)

    # @task(3)
    # def view_items(self):
    #     for item_id in range(10):
    #         self.client.get(f"/item?id={item_id}", name="/item")

    def on_start(self):
        pass
    def on_stop(self):
        pass

if __name__ == '__main__':
    import os
    os.system(" locust -f locustfile.py  ")